<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.dingpeikeji.quickdeer.modules.base.web.FSysController"%>
<%@page import="com.dingpeikeji.quickdeer.core.common.utils.CookieUtils"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>忘记密码</title>
<link href="${ctxStatic }/index/password/password.css" rel="stylesheet">
<jsp:include page="/WEB-INF/views/layouts/head.jsp"></jsp:include>
<script src="${ctxStatic}/jquery/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function(){
		 $("#btn").attr("disabled", true);
		 $("#subBtn").attr("disabled", true); 
		 $("#password1").click(function(){
				$("#password2").val("");
			})
		var keyVal2 = "${sessionScope.mes}";
		if(keyVal2.length!=0){  
			alert(keyVal2);
			if(keyVal2=='密码修改成功,请重新登录'){
				window.location.href = '${pageContext.request.contextPath }/login.jsp';
			}
		}
		$("input[name='mobile']").blur(function(){
			//获取输入的值
			var $value=$(this).val();
			if($value.length!=0){  
				$.post("${ctxFront}/sms/checkTel", {"mobile":$value},function(d){
					if(d==1){
						$("#mobilTip").html("<font color='red'>*手机号码未注册,无法重置密码</font>");
					}else if(d==0){
						$("#mobilTip").html("<font color='green'>*可以使用</font>");
						$("input[name='password2']").blur(function(){
							//获取输入的值
							var $password1=$("#password1").val();
							var $password2=$("#password2").val();
							if($password1.length!=0 && $password2.length!=0){
								$.post("${ctxFront}/sms/checkPassword",{"password1":$password1,"password2":$password2},function(d){
									if(d==0){
										$("#confirmTip").html("<font color='red'>*两次输入的密码不一致</font>");
									}else if(d==1){
										$("#confirmTip").html("<font color='red'>*6-16位数字和字母的组合</font>");
									}else if(d==2){
										$("#confirmTip").html("<font color='green'>*可以使用</font>");
										$('#btn').removeAttr('disabled');
										$("#btn").click(function(){
											$.post('${ctxFront}/sms/send', {"phone":$value,"type":2},function(data) {
												if (data != 'success') {
													alert(data);
												} else{
													$('#subBtn').removeAttr('disabled')
												}
											});
										});
									}
								});
							}
						});
					}else if(d==2){
						$("#mobilTip").html("<font color='red'>*手机号码格式不正确</font>");
					}
				});
			}
		});	
		
	})
	var countdown = 60;
	function settime(obj) {
		if (countdown == 0) {
			obj.removeAttribute("disabled");
			obj.text = "获取";
			countdown = 60;
			return;
		} else {
			obj.setAttribute("disabled", true);
			obj.text = "重发(" + countdown + ")";
			countdown--;
		}
		setTimeout(function() {
			settime(obj)
		}, 1000)
	};
</script>
<%session.removeAttribute("mes");%>
</head>
<body>
<article style="width: 100%;float: left;">
<div class="d_password">
<div class="d_password_1">
<h4 class="d_password_2">忘记密码</h4>
    <form class="d_form" action="${ctxFront}/user/forgetPwd" method="post" id="registerForm">
        <dl class="d_form_1">
            <dd><span>手机号码：</span>
            <input type="text" name="mobile" placeholder="请输入手机号码">
            <span id="mobilTip" ></span>
            </dd>
        </dl>
        <dl class="d_form_1">
            <dd ><span>新密码：</span><input type="password" name="password1" id="password1" placeholder="请输入新密码">
			<span id="newPasswordTip" class="onshow"></span> </dd>
        </dl >
        <dl class="d_form_1">
            <dd ><span>确认密码：</span><input type="password" name="password2" id="password2" placeholder="请输入新密码"> 
            	<span id="confirmTip" class="onshow"></span>
            </dd>
        </dl >
         <dl class="d_form_1">
            <dd><span>验证码：</span>
            <input type="text" name="validateCode" id="validateCode" placeholder="&nbsp;&nbsp;请输入验证码" style="width: 100px;">
             <a href="javascript:void(0)" id="btn" class="btnop" value="发送"  onclick="settime(this)">发送</a>
            </dd>
        </dl>
        <div style="text-align: center;padding-top: 50px;">
        	<input type="submit" class="reset" id="subBtn"  value="重置密码">
        </div>
        <div style="text-align: center;padding: 15px 0;">
            <a class="ples" href="${pageContext.request.contextPath }/login.jsp">已有账号，请登录</a>
        </div>
    </form>
    
</div>
</div>
</article>
	<jsp:include page="/WEB-INF/views/layouts/foot.jsp"></jsp:include> 
</body>
</html>	
